<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\AuthorizationsController;
use App\Http\Controllers\Api\TaskController;
use App\Http\Controllers\Api\CategoryController;
use App\Http\Controllers\Api\BannerController;
use App\Http\Controllers\Api\UserController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

//Route::get('/users', 'UsersController@index')->name('users.index');
//Route::get('/users/{user}', 'UsersController@show')->name('users.show');
//Route::get('/users/create', 'UsersController@create')->name('users.create');
//Route::post('/users', 'UsersController@store')->name('users.store');
//Route::get('/users/{user}/edit', 'UsersController@edit')->name('users.edit');
//Route::put('/users/{user}', 'UsersController@update')->name('users.update');
//Route::delete('/users/{user}', 'UsersController@destroy')->name('users.destroy');

Route::prefix('v1')
    ->namespace('App\Http\Controllers\Api')
    ->name('api.v1.')
    ->group(function () {
        Route::post('authorizations', [AuthorizationsController::class, 'store'])->name('authorizations.store');
        Route::get('task',[TaskController::class,'index'])->name('task.index');
        Route::post('task',[TaskController::class,'store'])->name('task.store');
        Route::get('task/{id}',[TaskController::class,'show'])->name('task.show');
        Route::get('category',[CategoryController::class,'index'])->name('category.index');
        Route::get('banner',[BannerController::class,'index'])->name('banner.index');

        //需要认证的接口
        Route::middleware('auth:api')->group(function (){
            Route::get('users/info',[UserController::class,'info'])->name('users.info');
        });
    });

